package org.xq.softcup.mq.util;

import java.util.HashMap;

public class ClassUtil {
    private static final HashMap<String, Class<?>> primClasses = new HashMap();

    static
    {
        primClasses.put("boolean", Boolean.TYPE);
        primClasses.put("byte", Byte.TYPE);
        primClasses.put("char", Character.TYPE);
        primClasses.put("short", Short.TYPE);
        primClasses.put("int", Integer.TYPE);
        primClasses.put("long", Long.TYPE);
        primClasses.put("float", Float.TYPE);
        primClasses.put("double", Double.TYPE);
        primClasses.put("void", Void.TYPE);
    }

    public static Class<?> resolveClass(String className)
            throws ClassNotFoundException
    {
        try
        {
            return Class.forName(className);
        }
        catch (ClassNotFoundException ex)
        {
            Class<?> cl = (Class)primClasses.get(className);
            if (cl != null) {
                return cl;
            }
            throw ex;
        }
    }
}
